package gorm

import "time"

type ExUsers struct {
	Id                       uint64                     `gorm:"column:id;type:bigint(20) unsigned;primary_key;AUTO_INCREMENT" json:"id"`
	UserName                 string                     `gorm:"column:user_name;type:varchar(100);comment:用户名;NOT NULL" json:"user_name"`
	Password                 string                     `gorm:"column:password;type:varchar(100);comment:密码;NOT NULL" json:"password"`
	UserEmail                string                     `gorm:"column:user_email;type:varchar(100);comment:邮箱;NOT NULL" json:"user_email"`
	UserMobile               string                     `gorm:"column:user_mobile;type:varchar(100);comment:手机号;NOT NULL" json:"user_mobile"`
	IsVip                    uint                       `gorm:"column:is_vip;type:tinyint(3) unsigned;default:0;comment:是否会员 1是0否;NOT NULL" json:"is_vip"`
	CreatedAt                time.Time                  `gorm:"column:created_at;type:timestamp" json:"created_at"`
	UpdatedAt                time.Time                  `gorm:"column:updated_at;type:timestamp" json:"updated_at"`
	IsDelete                 uint                       `gorm:"column:is_delete;type:tinyint(3) unsigned;default:0;comment:1删除;NOT NULL" json:"is_delete"`
	ExUserMoneyCouponRecords []*ExUserMoneyCouponRecord `gorm:"foreignKey:UserId;references:Id"`
}

func (e *ExUsers) TableName() string {
	return "ex_user"
}

type ExUserMoneyCouponRecord struct {
	Id         uint64    `gorm:"column:id;type:bigint(20) unsigned;primary_key;AUTO_INCREMENT" json:"id"`
	CouponName string    `gorm:"column:coupon_name;type:varchar(50);comment:现金券名;NOT NULL" json:"coupon_name"`
	CouponCode string    `gorm:"column:coupon_code;type:char(10);comment:现金券code;NOT NULL" json:"coupon_code"`
	IsDelete   int       `gorm:"column:is_delete;type:tinyint(4);default:0;comment:1删除 默认0;NOT NULL" json:"is_delete"`
	State      int       `gorm:"column:state;type:tinyint(4);default:1;comment:1可用 0不可用 默认1;NOT NULL" json:"state"`
	UserId     uint64    `gorm:"column:user_id;type:bigint(20) unsigned;default:0;comment:用户ID;NOT NULL" json:"user_id;"`
	StartTime  time.Time `gorm:"column:start_time;type:datetime;comment:可用开始时间;NOT NULL" json:"start_time"`
	EndTime    time.Time `gorm:"column:end_time;type:datetime;comment:可用结束时间;NOT NULL" json:"end_time"`
	CreatedAt  time.Time `gorm:"column:created_at;type:timestamp" json:"created_at"`
	UpdatedAt  time.Time `gorm:"column:updated_at;type:timestamp" json:"updated_at"`
}

func (e *ExUserMoneyCouponRecord) TableName() string {
	return "ex_user_money_coupon_record"
}
